<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title></title>
    <link href="${basePath}/css/bootstrap.min.css" rel="stylesheet">
    <script src="${basePath}/js/jquery-1.10.2.js"></script>
    <link rel="stylesheet" href="${basePath}/alert/iosOverlay.css">
 	<script src="${basePath}/alert/iosOverlay.js"></script>
    <script type="text/javascript">
	    function setpass(){
	    	//确认密码错误 
	    	var oldpassword = $("#old_password").val();
	    	var password = $("#password").val();
	    	var confirm = $("#confirm").val();
	    	
	    	if(oldpassword != "${user.password}"){
	    		iosOverlay({text: "旧密码输入错误",duration: 1e3,icon: "${basePath}/alert/cross.png"});
	    	} else if(password == oldpassword) {
	    		iosOverlay({text: "新旧密码相同",duration: 1e3,icon: "${basePath}/alert/cross.png"});
	    	} else if(password == "" || password.length == 0) {
	    		iosOverlay({text: "密码不能为空",duration: 1e3,icon: "${basePath}/alert/cross.png"});
	    	} else if(password.length >30) {
	    		iosOverlay({text: "密码最长30位",duration: 1e3,icon: "${basePath}/alert/cross.png"});
	    	} else if(password != confirm) {
	    		iosOverlay({text: "确认密码错误",duration: 1e3,icon: "${basePath}/alert/cross.png"});
	    	} else {
	    		/*var id = $("#id").val();
	    		var password = $("#password").val();
	    		window.parent.location.href="${basePath}/setpassword?id="+id+"&password="+password;
	    		return;*/
	    		$("form").submit();
	    		return;
	    	}
	    	$("#old_password").val("");
	    	$("#password").val("");
	    	$("#confirm").val("");
	    }
    </script>
  </head>
  <body>
  	<div style="width:85%;margin: 0px auto;">
  		<div style="width:100%;margin: 30px auto 30px auto;">
		    <form action="${basePath}/setpassword" method="post" target="_top">
		    	<input type="hidden" name="id" value="${user.id}">
			  <div class="form-group form-group-lg" style="width: 250px;margin: 10px auto 10px auto;">
				  <label class="control-label" for="username">旧密码</label>
				  <input type="password" class="form-control" id="old_password">
				</div>
				<div class="form-group form-group-lg" style="width: 250px;margin: 10px auto 10px auto;">
				  <label class="control-label" for="password">新密码</label>
				  <input type="password" class="form-control" id="password" name="password">
				</div>
				<div class="form-group form-group-lg" style="width: 250px;margin: 10px auto 10px auto;">
				  <label class="control-label" for="confirm">确认密码</label>
				  <input type="password" class="form-control" id="confirm">
				</div>
			  <button type="button" class="btn btn-warning btn-block btn-lg" style="width: 250px;margin: 20px auto 15px auto;" onclick="setpass()">确认修改</button>
			  <button type="button" class="btn btn-default btn-block btn-lg" style="width: 250px;margin: 15px auto 30px auto;" onclick="location.href='${basePath}/setting'">返回</button>
			</form>
		</div>
	  </div>
    <script src="${basePath}/js/jquery.min.js"></script>
    <script src="${basePath}/js/bootstrap.min.js"></script>
  </body>
</html>